//引入资源 vue vue-router
import Vue from 'vue';
import VueRouter from 'vue-router';
import App from './app.vue';
import Home from './home.vue';
import Login from './login.vue';


Vue.use(VueRouter);

const router = new VueRouter();
router.addRoutes([
    { name: 'home', path: '/home', component: Home },
    { name: 'login', path: '/login/:id', component: Login },
]);
// router.beforeEach((to, from, next) => {
//     console.log(to.path); 可以完成url上锚点的改变
//     if (to.path === '/home') {
//         //想进入首页，必须登录，让其跳转
//         next('/login')
//     } else {
//         next();
//     }

// });


new Vue({
    el: '#app', //加入到router属性中
    router,
    render: c => c(App)
});
